define(function(require, exports, module) {
	
	var config = require("plugins/config/config.js");
	var router = require("plugins/tools/router.js");
	var win = require("plugins/tools/window.js");

	//初始化接口链接
	var INDEX_INIT_API = "/api/index/init";
	
	//默认桌面样式，桌面样式：window，normal
	var default_desktop = "normal";
	module.exports = {

		start : function() {
			var me = this;
			//遮罩加载数据
			var mask = layer.load(1, {
				shade:0.3
			});
			//文件夹路由
			router.addRouter("index/folder");
			//设置路由
			router.addRouter("index/profile");
			//页面标题
			$("title").text($.i18n.prop("system.title"));
			//获取数据接口
			$.get(INDEX_INIT_API, {}, function(data) {
				//绘制桌面
				me.render(data, function() {
					//启动
					me.launcher(data);
					//关闭图层
					layer.close(mask);
				}, false);
			}, "json");
		},
		launcher:function(data) {
			//添加路由
			router.addRouters(data.routers);
			//自动启动launcher下的模块
			seajs.use("launcher/run", function(run) {
				run.start(data.launchers);
			});
		},
		render:function(data, finish, fullscreen) {
			var desktopType = data.desktop ? data.desktop : default_desktop;
			//开始绘制
			seajs.use("plugins/desktop/" + desktopType, function(desktop) {
				desktop.render(data, fullscreen);
				finish();
			});
		}
	};

});